package com.woniu.gf.pawn.service.impl;


import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.woniu.gf.pawn.comm.core.domain.Product;
import com.woniu.gf.pawn.comm.core.domain.ProductBigType;
import com.woniu.gf.pawn.dao.ProductBigTypeMapper;
import com.woniu.gf.pawn.dao.ProductBrandBigTypeMapper;
import com.woniu.gf.pawn.dao.ProductMapper;
import com.woniu.gf.pawn.product.parma.FindProductBigTypePageParam;
import com.woniu.gf.pawn.service.IProductService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author Lucas
 * @since 2020-10-15
 */
@Service
public class ProductServiceImpl extends ServiceImpl<ProductMapper, Product> implements IProductService {

    @Autowired
    private ProductBigTypeMapper productBigTypeMapper;

    @Autowired
    private ProductBrandBigTypeMapper productBrandBigTypeMapper;

    @Autowired
    private ProductMapper productMapper;

    @Override
    public List<Map<Integer, String>> findMap() {
        return productBigTypeMapper.findMap() ;
    }

    @Override
    public List<Map<Integer, String>> findByBigId(Integer bigId) {
        return productBrandBigTypeMapper.findByBigId(bigId);
    }

    /**
     * 添加
     * @param product
     */
    @Override
    public void addProduct(Product product) {
        productMapper.insert(product);
    }

    /**
     * 分页
     * @param pages
     * @return
     */
    @Override
    public IPage<Product> selectPageVo(FindProductBigTypePageParam pages) {
        Page<Product> productPage = new Page<>(pages.getIndex(), pages.getSize());
        IPage<Product> productIPage = productMapper.selectPageVo(productPage, pages.getName());
        return productIPage;
    }

    @Override
    public void deleteProduct(List<Integer> ids) {
        productMapper.deleteProduct(ids);
    }
}
